// Fill out your copyright notice in the Description page of Project Settings.


#include "ProceduralMeshActor.h"

// Sets default values
AProceduralMeshActor::AProceduralMeshActor()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	TArray<FVector> Verties;
	TArray<int32> Triangles;
	TArray<FColor> VertexColors;

	pmc = CreateDefaultSubobject<UProceduralMeshComponent>("pmc");
	RootComponent = pmc;

	Verties.Add(FVector(0, 0, 0));
	Verties.Add(FVector(0, 200, 200));
	Verties.Add(FVector(0, 0, 200));
	Triangles.Add(0);
	Triangles.Add(1);
	Triangles.Add(2);
	VertexColors.Add(FColor(0, 0, 255));
	VertexColors.Add(FColor(255, 0, 0));
	VertexColors.Add(FColor(0, 255, 0));
	pmc->CreateMeshSection(0, Verties, Triangles, TArray<FVector>(), TArray<FVector2D>(), VertexColors, TArray<FProcMeshTangent>(), false);

	static ConstructorHelpers::FObjectFinder<UMaterial> mat(TEXT("Material'/Game/ProceduralMesh/ProceduralMesh_mat'"));
	if (mat.Object) {
		pmc->SetMaterial(0, mat.Object);
	}
}

// Called when the game starts or when spawned
void AProceduralMeshActor::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void AProceduralMeshActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

